package com.dvd.utils;
import java.util.*;
public class DateMaker {
	private static DateMaker datemaker = null;
	private DateMaker()
	{
	}
	public static DateMaker getInstance()
	{
		if(datemaker==null)
		{
			datemaker = new DateMaker();
		}
		return datemaker;
	}
	public Date parse(String dateString)
	{
		int year = Integer.parseInt(dateString.substring(0,4));
		int month = Integer.parseInt(dateString.substring(5,7));
		int day = Integer.parseInt(dateString.substring(8, 10));
		Calendar cal= Calendar.getInstance();
		cal.set(year, month, day, 0, 0, 0);
		return cal.getTime();
	}
	
	public String getYear(Date date)
	{
		Calendar instance = Calendar.getInstance();
		instance.setTime(date);
		
		String year = String.format("%04d",instance.get(Calendar.YEAR));
		return year;
	}
	public String getDay(Date date)
	{
		Calendar instance = Calendar.getInstance();
		instance.setTime(date);
		String day = String.format("%02d",instance.get(Calendar.DAY_OF_MONTH));
		return day;
	}
	public String getMonth(Date date)
	{
		Calendar instance = Calendar.getInstance();
		instance.setTime(date);
		String month = String.format("%02d",instance.get(Calendar.MONTH));
		return month;
	}
	public static void main(String [] args)
	{
		DateMaker dm = DateMaker.getInstance();
		Date date = DateMaker.getInstance().parse("2010-06-04");
		System.out.println(date);
		System.out.println(dm.getYear(date)+"  "+ dm.getMonth(date)+"  "+dm.getDay(date));
	}
}
